﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace JXT.PrimaryKey.Batman.Reflection
{
    /// <summary>
    /// 模型缓存对象
    /// </summary>
    public class LambdaReflectionMetadate
    {
        /// <summary>
        /// 属性名
        /// </summary>
        public string Name { get; private set; }

        /// <summary>
        /// Lambda属性对象
        /// </summary>
        public LambdaPropertyInfo Property { get; private set; }

        /// <summary>
        /// 属性所有的Attribute对象数组
        /// </summary>
        public object[] Attributes { get; private set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="name">属性名</param>
        /// <param name="lambdaProperty">高级属性</param>
        /// <param name="attributes">特性数组</param>
        internal LambdaReflectionMetadate(string name, LambdaPropertyInfo lambdaProperty, object[] attributes)
        {
            Name = name;
            Property = lambdaProperty;
            Attributes = attributes;
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="propertyInfo">属性对象</param>
        internal LambdaReflectionMetadate(PropertyInfo propertyInfo)
        {
            if (propertyInfo == null)
                throw new ArgumentNullException("propertyInfo");
            Name = propertyInfo.Name;
            Property = new LambdaPropertyInfo(propertyInfo);
            Attributes = propertyInfo.GetCustomAttributes(true);
        }
    }
}
